<template>
  <div class="navbar">
    <div class="left" @click="goBack">
      <slot name="left">
        <span class="iconfont icon-jiantou1" style="color: #fff"></span>
      </slot>
    </div>
    <div class="center"><slot name="center"></slot></div>
    <div class="right"><slot name="right"></slot></div>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'
export default {
  name: 'NavBar',
  setup() {
    // 生成router实例
    const router = useRouter()
    function goBack() {
      router.back()
    }
    return {
      goBack
    }
  }
}
</script>

<style lang="scss" scoped>
.navbar {
  // position: fixed;
  // top: 0;
  // left: 0;
  // right: 0;
  // height: 0.44rem;
  background: var(--color-tint);
  display: flex;
  box-shadow: 0 1px 0px rgba(100, 100, 100, 0.1);
  z-index: 100;
  .left,
  .right {
    min-width: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .center {
    flex: 1;
    text-align: center;
    line-height: 0.44rem;
  }
}
</style>